{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from sklearn import datasets, linear_model,discriminant_analysis,cross_validation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 加载数据方法，这里使用scikit-learn自带的糖尿病病人的数据集\n",
    "def load_data():\n",
    "    diabetes = datasets.load_diabetes()\n",
    "    return cross_validation.train_test_split(diabetes.data, diabetes.target,test_size=0.25,random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 岭回归模型\n",
    "def test_Ridge(*data):\n",
    "    train_x,test_x, train_y, test_y = data\n",
    "    regr = linear_model.Ridge()\n",
    "    regr.fit(train_x, train_y)\n",
    "    \n",
    "    # y=wx+b  分别显示权重及b值\n",
    "    print('【权重】coefficient:{0}'.format(regr.coef_))\n",
    "    print('【b值】intercept: {0}'.format(regr.intercept_))\n",
    "    # 均方差\n",
    "    print('【均方差】residual sum of squares:{0}'.format(np.mean((regr.predict(test_x) -test_y)**2)))\n",
    "    # 成绩\n",
    "    print('【成绩】Testing Score: {0}'.format(regr.score(test_x,test_y)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "【权重】coefficient:[  21.19927911  -60.47711393  302.87575204  179.41206395    8.90911449\n",
      "  -28.8080548  -149.30722541  112.67185758  250.53760873   99.57749017]\n",
      "【b值】intercept: 152.4477761489962\n",
      "【均方差】residual sum of squares:3192.3285539937624\n",
      "【成绩】Testing Score: 0.35695757658096805\n"
     ]
    }
   ],
   "source": [
    "# 用糖尿病数据进行测试\n",
    "train_x,test_x, train_y, test_y = load_data()\n",
    "test_Ridge(train_x, test_x, train_y, test_y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 不同的α对结果的影响\n",
    "def test_Ridge_alpha(*data):\n",
    "    train_x,test_x, train_y, test_y = load_data()\n",
    "    alphas = np.logspace(-2, 5 ,num=200)\n",
    "    test_score = []\n",
    "    for i,alpha in enumerate(alphas):\n",
    "        regr = linear_model.Ridge(alpha=alpha)\n",
    "        regr.fit(train_x,train_y)\n",
    "        test_score.append(regr.score(test_x,test_y))\n",
    "        \n",
    "    # 绘图：\n",
    "    fig = plt.figure()\n",
    "    ax = fig.add_subplot(111)\n",
    "    ax.plot(alphas,test_score, label='Testing Score')\n",
    "    ax.set_xlabel(r'$\\alpha$')\n",
    "    ax.set_ylabel(r'score')\n",
    "    ax.set_ylim(0,0.4)\n",
    "    ax.set_title('Ridge')\n",
    "    ax.set_xscale('log')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEaCAYAAADg2nttAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xt4VfWd7/H3N3cC4RISEiARUIIIglADWu+2KmgVbKuorR3seOqxR6fT06c91dNOdeycZ3qZdtpObRVtre1UqbWtxSte6v1KkIsG5I7cIRBIIJCEJN/zx17YbQzsHcjK2jv5vJ5nP+y11m8ln2yRT9bd3B0REZEjyYg6gIiIpD6VhYiIJKSyEBGRhFQWIiKSkMpCREQSUlmIiEhCKguRY2Rmd5nZvxxhuZvZ6O7MJNLVTNdZiCRmZuuBEqAV2Ac8Bdzs7vuSWNeBCndfHWpIkRBpy0IkeZe5ez9gEjAZuDXiPCLdRmUh0knuvg2YT6w0MLPfmNm/HVpuZt8ws61mtsXM/jF+XTMbb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b6MbdfLfh0N/b3cDuV3x/Xv0bqjD6OgGhx+5SWGcfwIuAK4wsxvDDHYYncprZoPN7C5gssWeCRKVw+X+M/BZM/slx3argq7WYd4U+jzjHe6zjfrv6uEc7rM9z8x+ZmZ3A09EE+0jOszq7t9y968SK7R7ursojuBwn+1ngs/1d8TutXfMevSWRVdw958BP4s6R7LcfRexfdYpyd0bgC9GnSNZqf55xkvDv6svAC9EHKNT3P03UWdIhrv/mdgvZl2mN25ZHOtNCrtbuuU9JN1yp1PedMoK6ZU3nbJCN+btjWWxAKgws1FmlkPsoNW8iDMdSbrlPSTdcqdT3nTKCumVN52yQnfmjeKofjeePfAgsBU4SGxf3vXB/EuI3RF3DfCtqHOma950zZ1OedMpa7rlTaesqZBXNxIUEZGEeuNuKBER6SSVhYiIJKSyEBGRhFQWIiKSkMpCREQSUlmIiEhCKgsREUlIZSEiIgnpRoIiITKz8cBPgeOI3QF0CPBbd18QaTCRTtIV3CIhMbM84G3gSmAt8B6w0N0/E2kwkaOgLQuR8FwALHL3aoDgRm8/ijaSyNHRMQuR8EwCFgGY2TBgn7u/Gm0kkaOjshAJTzN/f6rhvxN7RrJIWlJZiITnAeAcM1sBLAFeN7OfRJxJ5KjoALeIiCSkLQsREUlIZSEiIgmpLEREJCGVhYiIJKSyEBGRhFQWIiKSkMpCREQSUlmIiEhC/x87a9+w8PKG6QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 用糖尿病数据进行测试\n",
    "train_x,test_x, train_y, test_y = load_data()\n",
    "test_Ridge_alpha(train_x, test_x, train_y, test_y)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
